package com.packagetracker.carriers;

import java.util.LinkedList;

import com.google.android.maps.GeoPoint;

public class PackageLocation {
	
	private String city;
	private String stateProvinceCode;
	private String postalCode;
	private String countryCode;
	private GeoPoint point;
	private LinkedList<PackageDetails> details;
	
	public PackageLocation() {
		this.details = new LinkedList<PackageDetails>();
	}
	
	public String getCity() {
		return this.city;
	}
	
	public String getStateProvinceCode() {
		return this.stateProvinceCode;
	}
	
	public String getPostalCode() {
		return this.postalCode;
	}
	
	public String getCountryCode() {
		return this.countryCode;
	}
	
	public GeoPoint getGeoPoint() {
		return this.point;
	}
	
	public LinkedList<PackageDetails> getDetails() {
		return this.details;
	}
	
	public void setCity(final String city) {
		this.city = city;
	}
	
	public void setStateProvinceCode(final String stateProvinceCode) {
		this.stateProvinceCode = stateProvinceCode;
	}
	
	public void setPostalCode(final String postalCode) {
		this.postalCode = postalCode;
	}
	
	public void setCountryCode(final String countryCode) {
		this.countryCode = countryCode;
	}
	
	public void setGeoPoint(final double latitude, final double longitude) {
		this.point = new GeoPoint((int)(latitude * 1e6), (int)(longitude * 1e6));
	}
	
	public void addDetails(final PackageDetails details) {
		this.details.addLast(details);
	}
	
	@Override
	public String toString() {
		final StringBuffer buffer = new StringBuffer();
		buffer.append(this.getCity());
		buffer.append(", ");
		buffer.append(this.getStateProvinceCode());
		
		if (this.getCountryCode() != null) {
			buffer.append(", ");
			buffer.append(this.getCountryCode());
		}
		
		if (this.getPostalCode() != null) {
			buffer.append(", ");
			buffer.append(this.getPostalCode());
		}
		
		return buffer.toString();
	}
	
}